package com.ning.cms.web.controller;

import com.ning.cms.service.ConfigService;
import com.ning.common.web.response.Result;
import com.ning.logging.anno.LoggingAccess;
import com.ning.user.bean.Config;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@Api(tags = "配置模块")
@RequestMapping("/config")
public class ConfigController {
    @Autowired
    private ConfigService configService;

    @LoggingAccess
    @ApiOperation(value = "查询所有启动的配置")
    @GetMapping("/select_config_status_with_on")
    public Result selectConfigStatusWithOn(){
        List<Config> configs = configService.selectConfigStatusWithOn();
        return Result.success(configs);
    }

    @LoggingAccess
    @ApiOperation(value = "添加配置")
    @PostMapping("/add_config")
    public Result addConfig(@RequestBody @Valid Config config){
        configService.addConfig(config);
        return Result.success("添加成功");
    }
}
